﻿using System;
using static Utility.WinAPI;

namespace WallpaperEngine
{
    public static class ShellTray
    {
        private static bool allowTransparency;

        private static IntPtr shellTray = FindWindow("Shell_TrayWnd", null);

        private static uint Transparency = 100;

        public static bool AllowTransparency
        {
            get => allowTransparency;
            set
            {
                allowTransparency = value;
                if (allowTransparency)
                {
                    SetWindowLong(shellTray, WindowLongFlags.GWL_EXSTYLE,GetWindowLong(shellTray, WindowLongFlags.GWL_EXSTYLE) | (int)WindowStylesEx.WS_EX_LAYERED);
                    SetLayeredWindowAttributes(shellTray, 0, Transparency, 2);//LWA_ALPHA=2
                }
                else
                {
                    SetLayeredWindowAttributes(shellTray, 0, 255, 2);//LWA_ALPHA=2
                }
            }
        }
    }
}
